﻿@model CurrencySelectorModel
@using IT.CMS.Web.Models.Common;
@using IT.CMS.Core;
@using IT.CMS.Core.Infrastructure;
@using IT.CMS.Core.Infrastructure.DependencyManagement;
@if (Model.AvailableCurrencies.Count > 1)
{
    var webHelper = EngineContext.Current.Resolve<IWebHelper>();
    
    var currencies = Model.AvailableCurrencies.Select(x => new SelectListItem
        {
            Text = x.Name,
            Value = webHelper.ModifyQueryString(Url.RouteUrl("ChangeCurrency", new { customercurrency = x.Id }), "returnurl=" + HttpUtility.UrlEncode(HttpContext.Current.Request.RawUrl), null),
            Selected = x.Id.Equals(Model.CurrentCurrencyId)
        });
    
    @Html.DropDownList("customerCurrency", currencies, new { onchange = "setLocation(this.value);" })
}